package com.codez.ftp;

import java.io.IOException;
import java.net.SocketException;

import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;

/**
 *  不值一看的代码
 * @author Admin
 *
 */
public class FtpDemo {

	public static void main(String[] args) throws SocketException, IOException {
		
		FTPClient client = new FTPClient();
		client.connect("47.107.69.108", 21);
		boolean login = client.login("ftp123", "ftp123");
		if(!login) {
			System.out.println("登录失败!");
		}
		int replyCode = client.getReplyCode();
		client.enterLocalPassiveMode();
//				client.enterLocalActiveMode();
		
		client.changeWorkingDirectory("/home/ftp123");
		
		System.out.println(client.printWorkingDirectory());
		client.changeToParentDirectory();
		System.out.println(client.printWorkingDirectory());
		System.out.println(client.changeWorkingDirectory("/"));;
		System.out.println(client.printWorkingDirectory());
		System.out.println(client.changeWorkingDirectory("home"));;
		System.out.println(client.printWorkingDirectory());
		System.out.println(client.changeWorkingDirectory("home"));;
		System.out.println(client.printWorkingDirectory());
		
		FTPFile[] listFiles = client.listFiles();
		for (FTPFile ftpFile : listFiles) {
//			System.out.println(ftpFile.getName());
		}
		
	}
	
	
	
}
